#include<iostream>
#include<fstream>
#include<string>
using namespace std;
const double critsc=0.83;
const int critmo=4;
struct node
{
    string a[2];
    double b;
    int c;
    node *next;
};
ifstream fin;
ofstream fout;
bool getitem(node *tt)
{
    if(!fin.eof())
    {
	fin>>tt->a[0]>>tt->a[1];
	fin>>tt->b>>tt->c;
	return 0;
    }
    else 
	return 1;
}
int main()
{
    node *head;
    node *tt,*tail;
    head=new node;
    tail=tt=head;
    getitem(tail);
    fin.open("/home/pi/code/al/sort.txt");
    fout.open("/home/pi/code/al/ns.txt",ios_base::app);
    bool ot=0;
    int d=0;
    while(true)
    {
	tt=new node;
	if(!getitem(tt))
	{
	    if(tt->a[0]==tail->a[0])
	    {
		tt->next=NULL;
		tail->next=tt;
		tail=tt;
		continue;
	    }
	    else
	    {
		int ix=0;
		int ox=0;
		node *temp=head;
		for(temp;temp!=NULL;temp=temp->next)
		    ix++;
		ox=ix/10;
		while(true)
		{
		    if(ox>15)
			ox=ox*4/5;
		    else
			break;
		}
		//cout<<ix<<"\t"<<ox<<endl;
		temp=head;
		ix=0;
		for(temp=head;temp!=NULL;temp=temp->next)
		{
		    if(ix<ox)
		    {
			if(ot==0)
			{
			    fout<<temp->a[0]<<"\t"<<temp->a[1];
			    ot=1;
			}
			else if(ot==1)
			    fout<<","<<temp->a[1];
			d++;
			ix++;
		    }
		    else if(temp->c>=critmo)
		    {
			if(ot==0)
			{
			    fout<<temp->a[0]<<"\t"<<temp->a[1];
			    ot=1;
			}
			else if(ot==1)
			    fout<<","<<temp->a[1];
			d++;

		    }
		}
		fout<<endl;
		ot=0;
		head=tail=tt;
	    }
	}
	else
	    break;
    }
    cout<<d<<endl;
    fout.close();
}

